<template>
<template v-if="value">
  <template v-if="or ? hasAnyPermissions(permissions) : hasAllPermissions(permissions)">
    <slot :keys="keys"/>
  </template>
</template>
<slot :keys="keys" v-else/>
</template>
<script setup lang="ts">
import { isArray } from 'lodash-es';
import { computed, PropType } from 'vue';
import { BaseType } from '../index';
import { hasAllPermissions, hasAnyPermissions, listPermissions } from './index'


const keys = listPermissions()
const { value } = defineProps({
  or: Boolean,
  value: {
    type: Array as PropType<Array<BaseType> | BaseType>,
  },
})

const permissions = computed(() => isArray(value) ? value : [value] as string[] | number[])
</script>
